package org.altervista.cp.thinjdbc;

import org.altervista.cp.thinjdbc.wrappers.SQLRuntimeException;

public class StoreQuery extends Query<Integer> {

	public StoreQuery(String sql) {
		super(sql.trim());
		if (!getSQLString().toLowerCase().startsWith("insert")
				&& !getSQLString().toLowerCase().startsWith("update")
				&& !getSQLString().toLowerCase().startsWith("delete")) {
			throw new SQLRuntimeException("Invalid SQL syntax: ["
					+ getSQLString()
					+ "], instead of one between: insert, update, delete");
		}
	}

	protected Integer executeActivated() {
		return getPreparedStatement().executeUpdate();
	}

}
